package com.ss.android.article.base.feature.detail2.e.a;

import android.content.Context;
import android.content.Intent;
import android.text.Html;

import com.ss.android.article.base.feature.e.ArticleShareHelper.a$a;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.browser.R;
import com.ss.android.common.lib.MobClickCombiner;

final class e implements a$a {
    private final CommonBizInteractor a;

    e(CommonBizInteractor arg1) {
        this.a = arg1;
    }

    public final void shareContent(long groupId) {
        String v1_2;
        if (this.a.hasView()) {
            String v0 = null;
            if (this.a.mNewDetailContext.articleDetail != null) {
                v0 = this.a.mNewDetailContext.articleDetail.content;
            }

            if (!this.a.hasView()) {
                return;
            }

            Article article = this.a.mNewDetailContext.article;
            if (article == null) {
                return;
            }

            if (article.groupId != groupId) {
                return;
            }

            if (this.a.mNewDetailContext.isNativePicGroup()) {
                return;
            }

            Context v3 = this.a.mContext;
            String v4 = article.title;
            String v5 = article.shareUrl;
            int v2_1 = article.commentCount;
            if (android.support.design.a.isTextEmpty(v0)) {
                android.support.design.a.showImageToast(v3, R.string.a0q, R.drawable.close_popup_textpage);
                return;
            }

            MobClickCombiner.onEvent(v3, "xiangping", "system_share_content");
            String v6 = "-----------------------------";
            try {
                v1_2 = v0.replaceFirst("\\s*<div\\s+id=\"toggle_img\"\\s*>\\s*<a(\\s+[a-zA-Z_]+=\"[^\"]*\")*\\s*>[^<>]*</a>\\s*</div>\\s*", "");
                v1_2 = v1_2.replaceFirst("<span\\s+class=\"time\"\\s*>[^<>]+</span>", "$0 <br/>" + v6 + "<br/>").replaceFirst("<div\\s+class=\"title\"\\s*>([^<>]+)</div>", "<b>$1</b><br/>").replaceAll("<a\\s+class=\"image\"\\s+href=\"bytedance://large_image[^\"]+\"\\s+origin_src=\"([^\"]+)\"\\s+thumb_src=\"[^\"]+\"(\\s+[a-zA-Z_]+=\"[^\"]*\")*\\s*>\\s*<span\\s+class=\"i-holder\"></span>\\s*<span\\s+class=\"t-holder\"\\s*>[^<>]*</span>", "<img src=\"$1\" /> $1 ").replaceFirst("<div\\s*id=\"src\">\\s*<a\\s*href=\"([^\"]+)\"\\s*>([^<>]+)</a>\\s*</div>", " ");
                v0 = v1_2.replaceAll("<style>[^<>]+</style>", " ");
            } catch (Exception exception) {
                exception.printStackTrace();
            }

            Intent intent = new Intent("android.intent.action.SEND");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            String v7 = v3.getString(com.ss.android.article.browser.R.string.dr);
            String v8 = v3.getString(com.ss.android.article.browser.R.string.app_name);
            StringBuilder v9 = new StringBuilder();
            v9.append("<p>(").append(v3.getString(com.ss.android.article.browser.R.string.html_share_text));
            v9.append(" <a href=\"").append(v7).append("\">");
            v9.append(v8).append("</a> ");
            v9.append(v7).append(")</p>");
            v9.append(v0);
            if (!android.support.design.a.isTextEmpty(v5)) {
                v9.append("<br/><a href=\"").append(v5).append("\">");
                v9.append(v3.getString(com.ss.android.article.browser.R.string.html_share_view_src)).append("</a> ").append(v5);
                v0 = String.format(v3.getString(com.ss.android.article.browser.R.string.html_share_view_comment), Integer.valueOf(v2_1));
                v9.append("<br/><a href=\"").append(v5).append("\">");
                v9.append(v0).append("</a> ").append(v5);
            }

            v9.append("<p> </p>" + v6 + "<br/>");
            intent.putExtra("android.intent.extra.TEXT", Html.fromHtml(v9.toString()));
            intent.putExtra("android.intent.extra.SUBJECT", String.format(v3.getString(com.ss.android.article.browser.R.string.vf), v4));
            intent.setType("message/rfc822");
            Intent v0_2 = Intent.createChooser(intent, v3.getString(com.ss.android.article.browser.R.string.c1));
            v0_2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                v3.startActivity(v0_2);
            } catch (Exception v0_1) {
            }
        }
    }
}

